<template>
  <div class="species-page">
    <!-- 面包屑 -->
    <div class="species-breadcrumb">
      <el-breadcrumb separator-class="el-icon-arrow-right">
        <el-breadcrumb-item :to="{ path: '/gene-data/home' }"
          >GeneData</el-breadcrumb-item
        >
        <el-breadcrumb-item>Browse</el-breadcrumb-item>
        <el-breadcrumb-item>Species</el-breadcrumb-item>
      </el-breadcrumb>
    </div>
    <el-scrollbar height="500px">
      <div class="species-content content-loading">
        <el-row :gutter="20">
          <el-col
            :span="6"
            v-for="(item, index) in state.speciesList"
            :key="index"
          >
            <div class="grid-content bg-purple">
              <p class="host_name">{{ item.host }}</p>
              <p @click="getSpeciesMessageByName(item.host)">
                <!-- <a href=""> -->
                <img src="../../assets/img/species.png" alt="" />
                <span>{{ item.speciesTotal }}</span>
                <!-- </a> -->
              </p>
            </div>
          </el-col>
        </el-row>
      </div>
    </el-scrollbar>
  </div>
</template>

<script setup>
import { reactive } from '@vue/reactivity'
import router from '@/router/index.js'
import { getAllSpeciesData, getAllSpeciesDataByHost } from '@/api/index.js'
let state = reactive({
  speciesList: []
})

getAllSpeciesData()
  .then((result) => {
    state.speciesList = result.data
    // console.log(state.speciesList)
  })
  .catch((err) => {
    console.log(err)
  })

let species = reactive({
  speciesName: '',
  speciesNumber: 0,
  speciesImgSrc: '../../assets/img/species.png'
})
let getSpeciesMessageByName = (value) => {
  router.push({ path: 'query/' + value })
  // console.log(value)
}
</script>

<style lang="scss" scoped>
.species-breadcrumb {
  width: 80%;
  margin: 5px auto;
  height: 50px;
  display: flex;
  align-items: center;
  // padding-left: 15px;
  .el-breadcrumb-item {
    color: #0c8c42;
  }
}
.host_name {
  text-overflow: ellipsis;
  white-space: nowrap;
  overflow: hidden;
}
.species-content {
  height: 100%;
  width: 80%;
  margin: 0 auto;
  padding-bottom: 100px;
  .el-col {
    cursor: pointer;
  }
  .grid-content {
    border: 1px solid rgb(230, 227, 227);
    border-top-color: #419641;
    margin-right: 3px;
    padding: 10px 0;
    margin-bottom: 20px;
    p {
      width: 100%;
      text-align: center;
      font-size: 20px;
      display: inline-block;
      img {
        width: 60px;
        height: 60px;
        margin: 10px 10px 0 0;
        vertical-align: middle;
      }
      span {
        color: #419641;
      }
    }
  }
}
</style>